<template>
  <div>
    <el-dialog title="所属的商铺信息" :visible.sync="visible">
      <el-table :data="dataList" border>
        <el-table-column prop="shopId" label="编号" align="center" header-align="center"/>
        <el-table-column prop="address" label="商铺地址" align="center" width="150px" header-align="center"/>
        <el-table-column prop="shopName" label="商铺名称" align="center" header-align="center"/>
        <el-table-column prop="status" label="状态" align="center" header-align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.status===1">正常</el-tag>
            <el-tag v-else type="danger">异常</el-tag>
          </template>
        </el-table-column>
      </el-table>
<!--      <el-pagination :current-page="pageIndex" :page-size="pageSize" :total="totalPage"
                     :page-sizes="[5,10,15,20,25]" layout="total,sizes,prev,pager,next,jumper"
                     @current-change="currentChange" @size-change="sizeChange"></el-pagination>-->
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'ShowShopList',
  data () {
    return {
      /* visible: false,
      spec: '',
      loading: '' */
      visible: false,
      dataList: [],
      pageIndex: 1,
      pageSize: 5,
      totalPage: 0,
      dataListLoading: false,
      cabinetId: ''
    }
  },
  methods: {
    /* init (cabinetId) {
      this.loading = this.$loading({ text: '加载中...' })
      this.$http.get('/cabinet/info/' + cabinetId).then(data => {
        this.loading.close()
        if (data.code === 0) {
          this.visible = true
          this.spec = data.list.shopId
        } else {
          this.$alert(data.msg, {
            type: 'error'
          })
        }
      })
    } */
    currentChange (val) {
      this.pageIndex = val
      this.getDataList()
    },
    sizeChange (val) {
      this.pageSize = val
      this.getDataList()
    },
    getDataList () {
      this.dataListLoading = this.$loading({ text: '加载表格...' })
      this.$http.get('/cabinet/shop/list/' + this.cabinetId, {
        page: this.pageIndex,
        limit: this.pageSize
      }).then(data => {
        this.dataListLoading.close()
        if (data.code === 0) {
          console.log(data.page)
          this.dataList = data.page.list
          this.totalPage = data.page.totalCount
        }
      })
    },
    init (cabinetId) {
      this.cabinetId = cabinetId
      this.visible = true
      this.getDataList()
    }
  }
}
</script>

<style scoped>

</style>
